package com.molichuxing.gateway.bff.payment.services.impl;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.molichuxing.framework.exception.BizException;
import com.molichuxing.framework.utils.BigDecimalUtils;
import com.molichuxing.framework.utils.DateUtil;
import com.molichuxing.framework.utils.DingTalkUtil;
import com.molichuxing.framework.utils.EmailUtil;
import com.molichuxing.gateway.bff.payment.convertor.Convert;
import com.molichuxing.gateway.bff.payment.entity.request.modify.AioPayResultModifyVo;
import com.molichuxing.gateway.bff.payment.entity.response.PaymentResultVo;
import com.molichuxing.gateway.bff.payment.services.PaymentResultBffService;
import com.molichuxing.gateway.contants.OrderConst;
import com.molichuxing.services.business.dto.request.create.MessageCenterCreateBizDto;
import com.molichuxing.services.business.dto.request.modify.OrderPayModifyBizDto;
import com.molichuxing.services.business.dto.response.NotifyBizDto;
import com.molichuxing.services.business.dto.response.OrderBizDto;
import com.molichuxing.services.business.dto.response.OrderExclusivelBizDto;
import com.molichuxing.services.business.dto.response.OrderMileageBizDto;
import com.molichuxing.services.business.dto.response.OrderSubscribeBizDto;
import com.molichuxing.services.business.dto.response.VehicleNameBizDto;
import com.molichuxing.services.business.service.MessageCenterBizService;
import com.molichuxing.services.business.service.OrderBizService;
import com.molichuxing.services.business.service.OrderDelayBizService;
import com.molichuxing.services.business.service.OrderExclusivelBizService;
import com.molichuxing.services.business.service.OrderSubscribeBizService;
import com.molichuxing.services.business.service.PaymentBizService;
import com.molichuxing.services.business.service.SmsBizService;
import com.molichuxing.services.business.service.VehicleBizService;
import com.molichuxing.services.infrastructure.dto.request.create.InvoiceCreateDto;
import com.molichuxing.services.infrastructure.dto.request.create.MessageCenterCreateDto;
import com.molichuxing.services.infrastructure.dto.request.create.MessageContentCreateDto;
import com.molichuxing.services.infrastructure.dto.request.create.NotifyPushCreateDto;
import com.molichuxing.services.infrastructure.dto.request.modify.OrderPayModifyDto;
import com.molichuxing.services.infrastructure.dto.response.DealerDetailDto;
import com.molichuxing.services.infrastructure.dto.response.MessageTemplateDto;
import com.molichuxing.services.infrastructure.dto.response.OrderExclusivelDto;
import com.molichuxing.services.infrastructure.dto.response.OrderMileageDto;
import com.molichuxing.services.infrastructure.dto.response.OrderRenegeDto;
import com.molichuxing.services.infrastructure.dto.response.OrderScheduleDto;
import com.molichuxing.services.infrastructure.dto.response.OrderSubscribeDto;
import com.molichuxing.services.infrastructure.dto.response.OrderSubscribeSettlementDto;
import com.molichuxing.services.infrastructure.dto.response.RiskEmailDto;
import com.molichuxing.services.infrastructure.dto.response.StoreDto;
import com.molichuxing.services.infrastructure.dto.response.UserDto;
import com.molichuxing.services.infrastructure.service.DealerDetailService;
import com.molichuxing.services.infrastructure.service.InvoiceService;
import com.molichuxing.services.infrastructure.service.MessageTemplateService;
import com.molichuxing.services.infrastructure.service.NotifyPushService;
import com.molichuxing.services.infrastructure.service.OrderExclusivelService;
import com.molichuxing.services.infrastructure.service.OrderMileageService;
import com.molichuxing.services.infrastructure.service.OrderRenegeService;
import com.molichuxing.services.infrastructure.service.OrderScheduleService;
import com.molichuxing.services.infrastructure.service.OrderSubscribeService;
import com.molichuxing.services.infrastructure.service.OrderSubscribeSettlementService;
import com.molichuxing.services.infrastructure.service.RiskEmailService;
import com.molichuxing.services.infrastructure.service.StoreService;
import com.molichuxing.services.infrastructure.service.UserDetailService;
import com.molichuxing.services.infrastructure.service.UserService;
import com.molichuxing.services.property.InvoiceTypeEnum;
import com.molichuxing.services.property.MessageCenterStatusEnum;
import com.molichuxing.services.property.MessageCenterTypeEnum;
import com.molichuxing.services.property.OrderExclusivelStatusEnum;
import com.molichuxing.services.property.OrderMileagePayStatusEnum;
import com.molichuxing.services.property.OrderPaymentMethodEnum;
import com.molichuxing.services.property.OrderRenegeStatusEnum;
import com.molichuxing.services.property.OrderScheduleStatusEnum;
import com.molichuxing.services.property.OrderSubscribeSettlementPayStatusEnum;
import com.molichuxing.services.property.OrderSubscribeStatusEnum;
import com.molichuxing.services.property.OrderTypeEnum;
import com.molichuxing.services.property.PaymentBusinessTypeEnum;
import com.molichuxing.services.property.PaymentCostTypeEnum;
import com.molichuxing.services.property.PaymentResultEnum;
import com.molichuxing.services.property.RiskEmailReceiveTypeEnum;
import com.molichuxing.services.property.RiskEmailTypeEnum;
import com.molichuxing.services.property.SmsTemplateEnum;


@Service("paymentResultBffService")
public class PaymentResultBffServiceImpl implements PaymentResultBffService {
	private static final Logger logger = LoggerFactory.getLogger(PaymentResultBffServiceImpl.class);

	@Value("${profiles.active}")
	private String ACTIVE;

	@Value("${profiles.active.explain}")
	private String ACTIVE_EXPLAIN;

	@Value("${email.account}")
	private String EMAIL_ACCOUNT;

	@Value("${email.password}")
	private String EMAIL_PASSWORD;

	@Resource
	private PaymentBizService paymentBizService;

	@Resource
	private OrderBizService orderBizService;

	@Resource
	private OrderScheduleService orderScheduleService;

	@Resource
	private OrderSubscribeSettlementService orderSubscribeSettlementService;

	@Resource
	private OrderExclusivelBizService orderExclusivelBizService;

	@Resource
	private OrderSubscribeBizService orderSubscribeBizService;

	@Resource
	private OrderMileageService orderMileageService;

	@Resource
	private OrderSubscribeService orderSubscribeService;

	@Resource
	private OrderExclusivelService orderExclusivelService;

	@Resource
	private OrderDelayBizService orderDelayBizService;

	@Resource
	private OrderRenegeService orderRenegeService;

	@Resource
	private UserService userService;

	@Resource
	private UserDetailService userDetailService;

	@Resource
	private InvoiceService invoiceService;

	@Resource
	private DealerDetailService dealerDetailService;

	@Resource
	private StoreService storeService;

	@Resource
	private MessageCenterBizService messageCenterBizService;

	@Resource
	private VehicleBizService vehicleBizService;

	@Resource
	private MessageTemplateService messageTemplateService;

	@Resource
	private SmsBizService smsBizService;

	@Resource
	private NotifyPushService notifyPushService;

	@Resource
	private RiskEmailService riskEmailService;

	/**
	 * 智能终端支付结果
	 * 
	 * @param modifyVo
	 * @return
	 * @throws Exception
	 * @throws BizException
	 */
	@Override
	public PaymentResultVo modifyAioPayResult(AioPayResultModifyVo modifyVo) throws BizException, Exception {
		PaymentResultVo result = new PaymentResultVo();
		NotifyBizDto notifyBizDto = paymentBizService.modifyAioResult(Convert.toAioPayResultBizModifyDto(modifyVo));
		if (PaymentResultEnum.SUCCESS.equals(notifyBizDto.getPayResult())) {
			// 查询订单信息
			OrderBizDto orderBizDto = orderBizService.getOrder(notifyBizDto.getOrderCode());
			// 修改订单信息
			modifyOrderPay(notifyBizDto, orderBizDto);
			result.setIsSuccess(true);
			if (OrderTypeEnum.SUBSCRIBE.equals(orderBizDto.getType())) {
				// 订阅
				result.setExplain(OrderConst.AIO_PAY_SUCCESS_EXPLAIN_ONE);
			} else if (OrderTypeEnum.EXCLUSIVEL.equals(orderBizDto.getType())) {
				// 专属
				OrderExclusivelBizDto orderExclusivel = (OrderExclusivelBizDto) orderBizDto;
				if (OrderPaymentMethodEnum.INSTALLMENT.equals(orderExclusivel.getPaymentMethod())) {
					// 分期
					result.setExplain(OrderConst.AIO_PAY_SUCCESS_EXPLAIN_ONE);
				} else if (OrderPaymentMethodEnum.FULL.equals(orderExclusivel.getPaymentMethod())) {
					// 全款
					result.setExplain(OrderConst.AIO_PAY_SUCCESS_EXPLAIN_TWO);
				}
			}
		} else {
			result.setIsSuccess(false);
			result.setExplain(OrderConst.AIO_PAY_ERROR_EXPLAIN);
		}

		return result;
	}

	/**
	 * 查询支付结果
	 * 
	 * @param orderCode
	 *            订单号
	 * @param scheduleId
	 *            排期id
	 * @param costType
	 *            费用类型
	 * @return
	 * @throws BizException
	 * @throws Exception
	 */
	@Override
	public PaymentResultVo getPaymentResult(Long orderCode, Integer scheduleId, PaymentCostTypeEnum costType)
			throws BizException, Exception {
		PaymentResultVo result = null;
		try {
			// 等待
			Thread.sleep(1500);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		// 根据订单号查询订单信息
		OrderBizDto orderBizDto = orderBizService.getOrder(orderCode);
		if (orderBizDto == null) {
			logger.error("查询支付结果信息异常，订单(" + orderCode + ")不存在");
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + "查询支付结果信息异常，订单(" + orderCode + ")不存在");
			throw new BizException("查询支付结果异常");
		}
		// 判断订单类型
		if (OrderTypeEnum.EXCLUSIVEL.equals(orderBizDto.getType())) {
			// 专属里程订单
			result = getExclusivelPaymentResult((OrderExclusivelBizDto) orderBizDto, scheduleId, costType);
			result.setOrderCode(orderBizDto.getOrderCode());
			result.setBusinessType(OrderTypeEnum.EXCLUSIVEL.getValue());
		} else if (OrderTypeEnum.SUBSCRIBE.equals(orderBizDto.getType())) {
			// 订阅里程订单
			result = getSubscribePaymentResult((OrderSubscribeBizDto) orderBizDto, costType);
			result.setOrderCode(orderBizDto.getOrderCode());
			result.setBusinessType(OrderTypeEnum.SUBSCRIBE.getValue());
		} else if (OrderTypeEnum.RELET_MILEAGE.equals(orderBizDto.getType())) {
			// 加购里程订单
			result = getPurchasePaymentResult((OrderMileageBizDto) orderBizDto, costType);
			result.setOrderCode(((OrderMileageBizDto) orderBizDto).getMasterOrderCode());
			result.setBusinessType(OrderTypeEnum.SUBSCRIBE.getValue());
		}

		result.setCostType(costType.getValue());

		return result;
	}

	/**
	 * 专属订单支付结果
	 * 
	 * @param orderBizDto
	 * @param scheduleId
	 * @param integer
	 * @return
	 */
	private PaymentResultVo getExclusivelPaymentResult(OrderExclusivelBizDto orderBizDto, Integer scheduleId,
			PaymentCostTypeEnum costType) throws BizException, Exception {
		PaymentResultVo result = new PaymentResultVo();
		result.setOrderCode(orderBizDto.getOrderCode());
		result.setServiceHotline(OrderConst.SERVICE_HOTLINE);
		result.setPaymentMethod(orderBizDto.getPaymentMethod().getValue());
		// 判断费用类型
		if (PaymentCostTypeEnum.SUBSCRIBE.equals(costType)) {
			// 订购
			if (OrderExclusivelStatusEnum.TRADE_UNPAID.equals(orderBizDto.getOrderStatus())) {
				// 待支付状态，查询支付服务信息
				if (getPaymentResultQuery(orderBizDto.getOrderCode(), null, costType)) {
					// 成功
					result.setIsSuccess(true);
					return result;
				} else {
					result.setIsSuccess(false);
					result.setPayAmount(orderBizDto.getCartFee().add(orderBizDto.getDeposit()));
					result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
					return result;
				}
			} else if (OrderSubscribeStatusEnum.TRADE_CANCELED.equals(orderBizDto.getOrderStatus())) {
				// 取消状态，返回失败
				result.setIsSuccess(false);
				result.setPayAmount(orderBizDto.getCartFee().add(orderBizDto.getDeposit()));
				result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
				return result;
			}
			result.setIsSuccess(true);
			// 判断付款方式
			if (OrderPaymentMethodEnum.FULL.equals(orderBizDto.getPaymentMethod())) {
				// 全款订单
				result.setExplain(OrderConst.PAY_EXCLUSIVEL_SUCCESS_EXPLAIN_ONE);
				return result;
			} else if (OrderPaymentMethodEnum.INSTALLMENT.equals(orderBizDto.getPaymentMethod())) {
				// 分期订单
				String explain = OrderConst.PAY_EXCLUSIVEL_SUCCESS_EXPLAIN_TWO;
				// 查询第二期排期信息
				OrderScheduleDto orderScheduleDto = orderScheduleService
						.getOrderScheduleByPeriods(orderBizDto.getOrderCode(), 2);
				explain = explain
						.replace("${nextPayableDate}", DateUtil.formatDate(orderScheduleDto.getPayableDate()))
						.replace("${nextPayable}", BigDecimalUtils.toString(orderScheduleDto.getPayable()));
				result.setExplain(explain);
				return result;
			}
			return result;
		} else if (PaymentCostTypeEnum.REPAYMENT.equals(costType)) {
			// 还款
			OrderScheduleDto orderScheduleDto = orderScheduleService.getOrderSchedule(scheduleId);
			if (orderScheduleDto == null) {
				logger.error("查询专属订单还款支付结果信息异常，排期(" + scheduleId + ")不存在");
				DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + "查询专属订单还款支付结果信息异常，排期(" + scheduleId + ")不存在");
				throw new BizException("查询支付结果异常");
			} else if (OrderScheduleStatusEnum.ALREADY.equals(orderScheduleDto.getStatus())) {
				// 已还款
				result.setIsSuccess(true);
				if (orderScheduleDto.getPeriods() == orderScheduleDto.getTotalPeriods()) {
					result.setExplain(OrderConst.PAY_EXCLUSIVEL_REPAY_SUCCESS_EXPLAIN_TWO);
					return result;
				}
				// 查询下一期期排期信息
				OrderScheduleDto nextOrderScheduleDto = orderScheduleService
						.getOrderScheduleByPeriods(orderBizDto.getOrderCode(), orderScheduleDto.getPeriods() + 1);
				String explain = OrderConst.PAY_EXCLUSIVEL_REPAY_SUCCESS_EXPLAIN_ONE;
				explain = explain
						.replace("${nextPayableDate}", DateUtil.formatDate(nextOrderScheduleDto.getPayableDate()))
						.replace("${nextPayable}", BigDecimalUtils.toString(nextOrderScheduleDto.getPayable()));
				result.setExplain(explain);
				return result;
			} else if (OrderScheduleStatusEnum.NO.equals(orderScheduleDto.getStatus())) {
				// 未还款，查询支付服务信息
				if (getPaymentResultQuery(orderBizDto.getOrderCode(), scheduleId, costType)) {
					result.setIsSuccess(true);
					return result;
				} else {
					result.setIsSuccess(false);
					result.setPayAmount(orderScheduleDto.getPayable());
					result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
					return result;
				}
			} else {
				result.setIsSuccess(false);
				result.setPayAmount(orderScheduleDto.getPayable());
				result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
				return result;
			}
		} else if (PaymentCostTypeEnum.RENEGE.equals(costType)) {
			// 退租缴费
			OrderRenegeDto orderRenegeDto = orderRenegeService.getRenege(orderBizDto.getOrderCode(),
					OrderRenegeStatusEnum.COMPLETE);
			if (orderRenegeDto == null) {
				logger.error("查询专属订单({})还款支付结果信息异常，不存在已完成退租信息", orderBizDto.getOrderCode());
				throw new BizException("查询支付结果异常");
			}
			// 判断状态
			if (!(OrderRenegeStatusEnum.COMPLETE.equals(orderRenegeDto.getRenegeStatus())
					&& OrderExclusivelStatusEnum.RENEGE_FINISH.equals(orderBizDto.getOrderStatus()))) {
				logger.error("查询专属订单({})还款支付结果信息异常，退租状态({})或订单状态({})异常", orderBizDto.getOrderCode(),
						orderRenegeDto.getRenegeStatus(), orderBizDto.getOrderStatus());
				throw new BizException("查询支付结果异常");
			}
			result.setIsSuccess(true);
			return result;

		} else {
			result.setIsSuccess(false);
			result.setPayAmount(orderBizDto.getCartFee().add(orderBizDto.getDeposit()));
			result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
			return result;
		}
	}

	/**
	 * 订阅订单支付结果
	 * 
	 * @param orderBizDto
	 * @param integer
	 * @return
	 */
	private PaymentResultVo getSubscribePaymentResult(OrderSubscribeBizDto orderBizDto, PaymentCostTypeEnum costType)
			throws BizException, Exception {
		PaymentResultVo result = new PaymentResultVo();
		result.setOrderCode(orderBizDto.getOrderCode());
		result.setServiceHotline(OrderConst.SERVICE_HOTLINE);
		// 判断费用类型
		if (PaymentCostTypeEnum.SUBSCRIBE.equals(costType) || PaymentCostTypeEnum.RENEW.equals(costType)) {
			// 订购或者续订
			if (OrderSubscribeStatusEnum.TRADE_UNPAID.equals(orderBizDto.getOrderStatus())) {
				// 待支付状态，查询支付服务信息
				if (getPaymentResultQuery(orderBizDto.getOrderCode(), null, costType)) {
					result.setIsSuccess(true);
					return result;
				} else {
					result.setIsSuccess(false);
					result.setPayAmount(orderBizDto.getCartFee().add(orderBizDto.getDeposit()));
					result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
					return result;
				}
			} else if (OrderSubscribeStatusEnum.TRADE_CANCELED.equals(orderBizDto.getOrderStatus())) {
				// 取消状态，返回失败
				result.setIsSuccess(false);
				result.setPayAmount(orderBizDto.getCartFee().add(orderBizDto.getDeposit()));
				result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
				return result;
			} else {
				result.setIsSuccess(true);
				if (orderBizDto.getParentOrderCode() == null) {
					// 订购
					result.setExplain(OrderConst.PAY_SUBSCRIBE_SUCCESS_EXPLAIN_ONE);
				} else {
					// 续订
					result.setExplain(OrderConst.PAY_SUBSCRIBE_SUCCESS_EXPLAIN_TWO);
				}
				return result;
			}
		} else if (PaymentCostTypeEnum.SETTLEMENT.equals(costType)) {
			// 结算
			OrderSubscribeSettlementDto orderSubscribeSettlementDto = orderSubscribeSettlementService
					.getOrderSubscribeSettlement(orderBizDto.getOrderCode());
			if (orderSubscribeSettlementDto == null) {
				logger.error("查询订阅订单结算支付结果信息异常，订单(" + orderBizDto.getOrderCode() + ")不存在");
				DingTalkUtil
						.exceptionSend(ACTIVE_EXPLAIN + "查询订阅订单结算支付结果信息异常，订单(" + orderBizDto.getOrderCode() + ")不存在");
				throw new BizException("查询支付结果异常");
			} else if (OrderSubscribeSettlementPayStatusEnum.WAIT.equals(orderSubscribeSettlementDto.getStatus())) {
				// 待支付，查询支付服务信息
				if (getPaymentResultQuery(orderBizDto.getOrderCode(), null, costType)) {
					result.setIsSuccess(true);
					return result;
				} else {
					result.setIsSuccess(false);
					result.setPayAmount(orderBizDto.getCartFee().add(orderBizDto.getDeposit()));
					result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
					return result;
				}
			} else {
				// 支付成功
				result.setIsSuccess(true);
				return result;
			}
		} else {
			result.setIsSuccess(false);
			result.setPayAmount(orderBizDto.getCartFee().add(orderBizDto.getDeposit()));
			result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
			return result;
		}
	}

	/**
	 * 加购订单支付结果
	 * 
	 * @param orderBizDto
	 * @return
	 */
	private PaymentResultVo getPurchasePaymentResult(OrderMileageBizDto orderBizDto, PaymentCostTypeEnum costType)
			throws BizException, Exception {
		PaymentResultVo result = new PaymentResultVo();
		result.setOrderCode(orderBizDto.getMasterOrderCode());
		result.setPayAmount(orderBizDto.getPurchaseFee().add(orderBizDto.getBeyondFee()));
		result.setServiceHotline(OrderConst.SERVICE_HOTLINE);
		if (OrderMileagePayStatusEnum.PREPAID.equals(orderBizDto.getStatus())) {
			// 支付成功，返回成功信息
			result.setIsSuccess(true);
		} else if (OrderMileagePayStatusEnum.CANCELED.equals(orderBizDto.getStatus())) {
			// 已取消，返回失败
			result.setIsSuccess(false);
			result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
		} else {
			// 查询支付服务
			if (getPaymentResultQuery(orderBizDto.getOrderCode(), null, costType)) {
				result.setIsSuccess(true);
			} else {
				result.setIsSuccess(false);
				result.setExplain(OrderConst.PAY_ERROR_EXPLAIN);
			}
		}
		return result;
	}

	/**
	 * 查询支付服务是否支付成功
	 * 
	 * @param orderBizDto
	 * @param scheduleId
	 * @param costType
	 * @param result
	 * @return
	 * @throws Exception
	 * @throws BizException
	 */
	private Boolean getPaymentResultQuery(Long orderCode, Integer scheduleId, PaymentCostTypeEnum costType)
			throws BizException, Exception {
		Boolean result = null;
		NotifyBizDto notifyBizDto = paymentBizService.getPayResult(orderCode, scheduleId, costType);
		if (PaymentResultEnum.SUCCESS.equals(notifyBizDto.getPayResult())) {
			// 成功
			result = true;
			// 修改订单信息
			// modifyOrderPay(notifyBizDto, null);
		} else {
			// 失败
			result = false;
		}
		return result;
	}

	/**
	 * 支付完成修改订单信息
	 * 
	 * @param notifyBizDto
	 * @param orderBizDto
	 */
	private void modifyOrderPay(NotifyBizDto notifyBizDto, OrderBizDto orderBizDto) {
		try {
			boolean result = false;
			// 查询用户信息
			UserDto userDto = userService.getUser(notifyBizDto.getUserId());
			// 判断业务类型
			if (PaymentBusinessTypeEnum.EXCLUSIVEL.equals(notifyBizDto.getBusinessType())) {
				// 专属订单
				result = this.modifyExclusivelOrderPay(notifyBizDto, userDto);
			} else if (PaymentBusinessTypeEnum.SUBSCRIBE.equals(notifyBizDto.getBusinessType())) {
				// 订阅订单
				result = this.modifySubscribeOrderPay(notifyBizDto, userDto);
			}
			if (result) {
				// 修改成功，进行其他操作
				otherOperation(notifyBizDto, userDto);
			} else {
				String str = JSONObject.toJSONString(notifyBizDto);
				logger.error("支付回调修改订单信息失败：{}", str);
				DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + "支付回调修改订单信息失败：" + str);
			}
		} catch (Exception e) {
			logger.error("[modifyOrderPay]支付(支付流水号：" + notifyBizDto.getPayNumber() + ")完成修改订单信息异常：", e);
			DingTalkUtil.exceptionSend(
					ACTIVE_EXPLAIN + "支付(支付流水号：" + notifyBizDto.getPayNumber() + ")完成修改订单信息异常：" + e.getMessage());
		}
	}

	/**
	 * 支付完成修改订阅订单信息
	 * 
	 * @param userDto
	 * 
	 * @param notifyBizDto
	 */
	private Boolean modifySubscribeOrderPay(NotifyBizDto notifyBizDto, UserDto userDto) {
		Boolean result = false;
		// 判断费用类型
		if (PaymentCostTypeEnum.SUBSCRIBE.equals(notifyBizDto.getCostType())) {
			// 订购
			OrderPayModifyBizDto modifyDto = Convert.toOrderPayModifyBizDto(notifyBizDto, userDto);
			result = orderSubscribeBizService.modifyPaySuccess(modifyDto);
		} else if (PaymentCostTypeEnum.RENEW.equals(notifyBizDto.getCostType())) {
			// 续订
			OrderPayModifyBizDto modifyDto = Convert.toOrderPayModifyBizDto(notifyBizDto, userDto);
			result = orderSubscribeBizService.modifyPaySuccess(modifyDto);
		} else if (PaymentCostTypeEnum.PURCHASE.equals(notifyBizDto.getCostType())) {
			// 加购
			OrderPayModifyDto modifyDto = Convert.toOrderPayModifyDto(notifyBizDto, userDto);
			orderMileageService.modifyPay(modifyDto);
		} else if (PaymentCostTypeEnum.SETTLEMENT.equals(notifyBizDto.getCostType())) {
			// 结算
			OrderPayModifyDto modifyDto = Convert.toOrderPayModifyDto(notifyBizDto, userDto);
			orderSubscribeSettlementService.modifyPay(modifyDto);
		}

		return result;
	}

	/**
	 * 支付完成修改专属订单信息
	 * 
	 * @param paymentCostTypeEnum
	 * 
	 * @param notifyBizDto
	 */
	private Boolean modifyExclusivelOrderPay(NotifyBizDto notifyBizDto, UserDto userDto) {
		Boolean result = false;
		// 判断费用类型
		if (PaymentCostTypeEnum.SUBSCRIBE.equals(notifyBizDto.getCostType())) {
			// 订购（首付）
			OrderPayModifyBizDto modifyDto = Convert.toOrderPayModifyBizDto(notifyBizDto, userDto);
			result = orderExclusivelBizService.modifyPaySuccess(modifyDto);
		} else if (PaymentCostTypeEnum.REPAYMENT.equals(notifyBizDto.getCostType())) {
			// 还款
			OrderPayModifyDto modifyDto = Convert.toOrderPayModifyDto(notifyBizDto, userDto);
			result = orderScheduleService.modifyPay(modifyDto);
		}
		return result;
	}

	private void otherOperation(NotifyBizDto notifyBizDto, UserDto userDto) {
		if (PaymentCostTypeEnum.SUBSCRIBE.equals(notifyBizDto.getCostType())) {
			// 订购
			// 将用户置为已支付
			modifyUserPay(userDto);
			// 去除延时任务
			try {
				orderDelayBizService.delete(notifyBizDto.getOrderCode());
			} catch (Exception e) {
				logger.error("支付完成，删除延时任务异常：", e);
			}
			// 发送短信、推送等
			pushMsgSubscribe(notifyBizDto, userDto);
			// 创建发票
			createSubscribeInvoice(notifyBizDto);
		}
	}

	private void pushMsgSubscribe(NotifyBizDto notifyBizDto, UserDto userDto) {
		try {
			JSONObject json = new JSONObject();
			Integer smsCode = null;
			VehicleNameBizDto vehicleName = null;
			StoreDto store = null;
			String product = null;
			NotifyPushCreateDto notifyPush = null;
			BigDecimal payAmount = null;
			boolean isAudit = false;
			String tmp = null;
			// 判断业务类型
			if (PaymentBusinessTypeEnum.EXCLUSIVEL.equals(notifyBizDto.getBusinessType())) {
				// 专属订单
				OrderExclusivelDto orderExclusivel = orderExclusivelService
						.getOrderExclusivel(notifyBizDto.getOrderCode());
				// 查询车型信息
				vehicleName = vehicleBizService.getCarByModel(orderExclusivel.getVehicleId());
				// 查询门店
				store = storeService.getStoreById(orderExclusivel.getPlaceStoreId());
				if (OrderPaymentMethodEnum.INSTALLMENT.equals(orderExclusivel.getPaymentMethod())) {
					// 月付
					smsCode = SmsTemplateEnum.ORDER_PAY_SMS_ONE.getValue();
					payAmount = orderExclusivel.getRental().add(orderExclusivel.getDeposit());
					isAudit = true;
					tmp = "专属里程";
				} else if (OrderPaymentMethodEnum.FULL.equals(orderExclusivel.getPaymentMethod())) {
					// 全款
					smsCode = SmsTemplateEnum.ORDER_PAY_SMS_TWO.getValue();
					payAmount = orderExclusivel.getRental().add(orderExclusivel.getDeposit());
				}
				// 商品名称
				String paymentMethodStr = OrderPaymentMethodEnum.INSTALLMENT.equals(orderExclusivel.getPaymentMethod())
						? "月付" : orderExclusivel.getPaymentMethod().getName();
				product = vehicleName.getSubBrandName() + " " + vehicleName.getSeriesName() + " "
						+ vehicleName.getModelName() + " " + orderExclusivel.getTransportTime() + "期/"
						+ (orderExclusivel.getIsBuyback() ? "回购/" : "不回购/") + paymentMethodStr;
				json.put("product", product);
				// 支付金额
				json.put("amount", BigDecimalUtils.toString(payAmount));
				// 门店
				json.put("store", store.getFullName());
				// 日期
				json.put("num", 15);

				// 推送数据
				MessageTemplateDto messageTemplateDto = messageTemplateService.getByKey("push_pay_success");
				String body = messageTemplateDto.getBody();
				body = body.replace("${goodsName}", product);
				notifyPush = new NotifyPushCreateDto(Arrays.asList(userDto.getPhone()), messageTemplateDto.getSubject(),
						messageTemplateDto.getSubject(), body, body, null, "");

			} else if (PaymentBusinessTypeEnum.SUBSCRIBE.equals(notifyBizDto.getBusinessType())) {
				// 订阅订单
				OrderSubscribeDto orderSubscribe = orderSubscribeService.getOrderSubscribe(notifyBizDto.getOrderCode());
				isAudit = true;
				tmp = "订阅里程";
				payAmount = orderSubscribe.getCartFee().add(orderSubscribe.getDeposit());
				smsCode = SmsTemplateEnum.ORDER_PAY_SMS_THREE.getValue();
				// 查询车型信息
				vehicleName = vehicleBizService.getCarByModel(orderSubscribe.getVehicleId());
				// 查询门店
				store = storeService.getStoreById(orderSubscribe.getPlaceStoreId());
				// 商品名称
				product = vehicleName.getSubBrandName() + " " + vehicleName.getSeriesName() + " "
						+ vehicleName.getModelName() + " " + orderSubscribe.getTransportTime() + "个月/"
						+ orderSubscribe.getBaseMileage() + "公里, " + orderSubscribe.getPackageMileage() + "公里";
				json.put("product", product);
				// 支付金额
				json.put("amount", BigDecimalUtils.toString(payAmount));
				// 门店
				json.put("store", store.getFullName());

				// 推送数据
				MessageTemplateDto messageTemplateDto = messageTemplateService.getByKey("push_pay_success_two");
				String body = messageTemplateDto.getBody();
				body = body.replace("${goodsName}", product).replace("${cost}", BigDecimalUtils.toString(payAmount))
						.replace("${date}", DateUtil.formatDate(LocalDate.now(), "yyyy年MM月dd日"))
						.replace("${store}", store.getFullName());
				notifyPush = new NotifyPushCreateDto(Arrays.asList(userDto.getPhone()), messageTemplateDto.getSubject(),
						messageTemplateDto.getSubject(), body, body, null, "");
			}
			// 发送短信
			try {
				smsBizService.sendMessage(userDto.getPhone(), smsCode, json.toJSONString(), null);
			} catch (Exception e) {
				logger.error(
						"订购(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber() + ")完成发送短信异常：",
						e);
			}
			// 发送推送
			try {
				notifyPushService.notifyPushByAlias(notifyPush);
			} catch (Exception e) {
				logger.error(
						"订购(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber() + ")完成发送推送异常：",
						e);
			}
			// 保存消息
			MessageCenterCreateBizDto messageCenterCreateBizDto = new MessageCenterCreateBizDto();
			MessageCenterCreateDto messageCenterCreateDto = new MessageCenterCreateDto();
			messageCenterCreateDto.setUserId(userDto.getId());
			messageCenterCreateDto.setTitle("支付成功通知");
			messageCenterCreateDto.setMessage("您成功支付了一笔款项");
			messageCenterCreateDto.setType(MessageCenterTypeEnum.SUCCESSFUL_PAYMENT_NOTICE.getValue());
			messageCenterCreateDto.setStatus(MessageCenterStatusEnum.UNREAD.getValue());
			List<MessageContentCreateDto> messageContentCreateDtos = new ArrayList<>();
			messageContentCreateDtos.add(new MessageContentCreateDto("支付时间",
					DateUtil.formatDate(notifyBizDto.getPayTime(), "yyyy年MM月dd日 HH:mm:ss"), 1));
			messageContentCreateDtos
					.add(new MessageContentCreateDto("支付金额", "¥" + BigDecimalUtils.toString(payAmount), 2));
			messageContentCreateDtos.add(new MessageContentCreateDto("支付单号", notifyBizDto.getPayNumber(), 3));
			messageContentCreateDtos.add(new MessageContentCreateDto("支付项目", product, 4));

			messageCenterCreateBizDto.setMessageCenterCreateDto(messageCenterCreateDto);
			messageCenterCreateBizDto.setMessageContentCreateDtoList(messageContentCreateDtos);
			messageCenterBizService.careteMessageCenterBiz(messageCenterCreateBizDto);

			if (isAudit) {
				// 发送审核信息给客服
				pushMsgToService(notifyBizDto, userDto, tmp);
			}

		} catch (Exception e) {
			String msg = "订购(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber()
					+ ")完成发送消息信息异常：";
			logger.error(msg, e);
		}
	}

	private void pushMsgToService(NotifyBizDto notifyBizDto, UserDto userDto, String tmp) {
		try {
			List<RiskEmailDto> riskEmailDtos = riskEmailService.getByType(RiskEmailTypeEnum.ORDER_ONE.getValue(), null);
			if (riskEmailDtos == null || riskEmailDtos.isEmpty()) {
				return;
			}
			JSONObject json = new JSONObject();
			// 用户姓名
			json.put("name", userDto.getRealName());
			// 手机号
			json.put("phone", userDto.getPhone());
			// 订单号
			json.put("order", notifyBizDto.getOrderCode());
			List<String> emailRecipients = new ArrayList<>();
			List<String> emailCopys = new ArrayList<>();
			String dingTalkUrl = null;
			for (RiskEmailDto riskEmailDto : riskEmailDtos) {
				if (riskEmailDto.getReceiveType() == RiskEmailReceiveTypeEnum.PHONE_SMS.getValue()) {
					try {
						Thread.sleep(100);
						// 发送短信
						smsBizService.sendMessage(riskEmailDto.getEmail(), SmsTemplateEnum.ORDER_AUDIT_SMS.getValue(),
								json.toJSONString(), null);
					} catch (Exception e) {
						logger.error("审核提醒({}:{})短信发送失败", riskEmailDto.getName(), riskEmailDto.getEmail());
					}
				} else if (riskEmailDto.getReceiveType() == RiskEmailReceiveTypeEnum.EMAIL_RECIPIENT.getValue()) {
					emailRecipients.add(riskEmailDto.getEmail());
				} else if (riskEmailDto.getReceiveType() == RiskEmailReceiveTypeEnum.EMAIL_COPY.getValue()) {
					emailCopys.add(riskEmailDto.getEmail());
				} else if (riskEmailDto.getReceiveType() == RiskEmailReceiveTypeEnum.DINGTALK_WEBHOOK.getValue()) {
					dingTalkUrl = riskEmailDto.getEmail();
				}
			}

			if (emailRecipients.isEmpty()) {
				return;
			}
			// 发送邮件
			String subject = "订单审核通知--" + notifyBizDto.getOrderCode();
			String content = "亲，有新的订阅里程服务订单需要审核，请尽快登录“OP后台》订单【" + tmp + "】”进行处理。<br />" + "订单编号："
					+ notifyBizDto.getOrderCode() + "<br />" + "用户姓名：" + userDto.getRealName() + "<br />" + "联系方式："
					+ userDto.getPhone() + "<br /><br />" + "此邮件为系统自动发送，请勿回复。";
			EmailUtil.sendMail(EMAIL_ACCOUNT, EMAIL_PASSWORD, subject, content, emailRecipients,
					(emailCopys.isEmpty() ? null : emailCopys));
			content = "亲，有新的【" + tmp + "】订单需要审核，用户姓名：" + userDto.getRealName() + "(" + userDto.getPhone() + ")，订单号："
					+ notifyBizDto.getOrderCode() + "，请尽快联系用户完成回访及订单审核。";
			// 发送钉钉
			DingTalkUtil.execute(dingTalkUrl, content);

		} catch (Exception e) {
			String msg = "订购(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber()
					+ ")完成发送审核信息给客服异常：";
			logger.error(msg, e);
		}
	}

	/**
	 * 结算支付发票
	 * 
	 * @param notifyBizDto
	 */
	private void createSettlementInvoice(NotifyBizDto notifyBizDto) {
		try {
			List<InvoiceCreateDto> invoiceCreateDtos = null;
			// 结算
			OrderSubscribeSettlementDto orderSubscribeSettlement = orderSubscribeSettlementService
					.getOrderSubscribeSettlement(notifyBizDto.getOrderCode());
			// 查询订单信息
			OrderSubscribeDto orderSubscribe = orderSubscribeService.getOrderSubscribe(notifyBizDto.getOrderCode());
			// 查询门店信息
			StoreDto storeDto = storeService.getStoreById(orderSubscribe.getPlaceStoreId());
			// 查询经销商信息
			DealerDetailDto dealerDetailDto = dealerDetailService.getDealerDetailById(storeDto.getDealerId());
			invoiceCreateDtos = new ArrayList<>();
			if (orderSubscribeSettlement.getDamageFee() != null
					&& orderSubscribeSettlement.getDamageFee().compareTo(BigDecimal.ZERO) > 0) {
				// 结算质损费用
				invoiceCreateDtos.add(Convert.toInvoiceCreateDto(notifyBizDto, orderSubscribe, dealerDetailDto,
						orderSubscribeSettlement.getDamageFee(), InvoiceTypeEnum.QUALITY_LOSS));
			}
			if (orderSubscribeSettlement.getBeyondMileageFee() != null
					&& orderSubscribeSettlement.getBeyondMileageFee().compareTo(BigDecimal.ZERO) > 0) {
				// 结算超里程费用
				invoiceCreateDtos.add(Convert.toInvoiceCreateDto(notifyBizDto, orderSubscribe, dealerDetailDto,
						orderSubscribeSettlement.getBeyondMileageFee(), InvoiceTypeEnum.BEYOND_MILEAGE));
			}
			if (orderSubscribeSettlement.getBeyondDayFee() != null
					&& orderSubscribeSettlement.getBeyondDayFee().compareTo(BigDecimal.ZERO) > 0) {
				// 结算超期费用
				invoiceCreateDtos.add(Convert.toInvoiceCreateDto(notifyBizDto, orderSubscribe, dealerDetailDto,
						orderSubscribeSettlement.getBeyondDayFee(), InvoiceTypeEnum.TIME_OUT));
			}
			// 生成发票信息
			createInvoice(invoiceCreateDtos, notifyBizDto.getPayNumber());
		} catch (Exception e) {
			String msg = "结算(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber()
					+ ")完成创建发票信息异常：";
			logger.error(msg, e);
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + msg + e.getMessage());
		}
	}

	/**
	 * 加购支付发票
	 * 
	 * @param notifyBizDto
	 */
	private void createPurchaseInvoice(NotifyBizDto notifyBizDto) {
		try {
			List<InvoiceCreateDto> invoiceCreateDtos = null;
			OrderMileageDto orderMileage = orderMileageService.getOrderMileage(notifyBizDto.getOrderCode());
			// 查询主订单信息
			OrderSubscribeDto orderSubscribe = orderSubscribeService
					.getOrderSubscribe(orderMileage.getMasterOrderCode());
			// 查询门店信息
			StoreDto storeDto = storeService.getStoreById(orderSubscribe.getPlaceStoreId());
			// 查询经销商信息
			DealerDetailDto dealerDetailDto = dealerDetailService.getDealerDetailById(storeDto.getDealerId());
			invoiceCreateDtos = new ArrayList<>();
			invoiceCreateDtos.add(Convert.toInvoiceCreateDto(notifyBizDto, orderSubscribe, dealerDetailDto,
					orderMileage.getPurchaseFee(), InvoiceTypeEnum.ADD_MILEAGE));
			if (orderMileage.getBeyondFee() != null && orderMileage.getBeyondFee().compareTo(BigDecimal.ZERO) > 0) {
				// 存在超里程
				invoiceCreateDtos.add(Convert.toInvoiceCreateDto(notifyBizDto, orderSubscribe, dealerDetailDto,
						orderMileage.getBeyondFee(), InvoiceTypeEnum.BEYOND_MILEAGE));
			}
			// 生成发票信息
			createInvoice(invoiceCreateDtos, notifyBizDto.getPayNumber());
		} catch (Exception e) {
			String msg = "加购(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber()
					+ ")完成创建发票信息异常：";
			logger.error(msg, e);
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + msg + e.getMessage());
		}
	}

	/**
	 * 续订支付发票
	 * 
	 * @param notifyBizDto
	 */
	private void createRenewInvoice(NotifyBizDto notifyBizDto) {
		try {
			List<InvoiceCreateDto> invoiceCreateDtos = null;
			OrderSubscribeDto orderSubscribe = orderSubscribeService.getOrderSubscribe(notifyBizDto.getOrderCode());
			// 查询门店信息
			StoreDto storeDto = storeService.getStoreById(orderSubscribe.getPlaceStoreId());
			// 查询经销商信息
			DealerDetailDto dealerDetailDto = dealerDetailService.getDealerDetailById(storeDto.getDealerId());
			invoiceCreateDtos = Arrays
					.asList(Convert.toInvoiceCreateDto(notifyBizDto, orderSubscribe, dealerDetailDto));
			// 生成发票信息
			createInvoice(invoiceCreateDtos, notifyBizDto.getPayNumber());
		} catch (Exception e) {
			String msg = "续订(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber()
					+ ")完成创建发票信息异常：";
			logger.error(msg, e);
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + msg + e.getMessage());
		}
	}

	/**
	 * 还款支付发票
	 * 
	 * @param notifyBizDto
	 */
	private void createRepaymentInvoice(NotifyBizDto notifyBizDto) {
		try {
			List<InvoiceCreateDto> invoiceCreateDtos = null;
			OrderExclusivelDto orderExclusivel = orderExclusivelService.getOrderExclusivel(notifyBizDto.getOrderCode());
			// 查询排期信息
			OrderScheduleDto orderScheduleDto = orderScheduleService.getOrderSchedule(notifyBizDto.getScheduleId());
			// 查询门店信息
			StoreDto storeDto = storeService.getStoreById(orderExclusivel.getPlaceStoreId());
			// 查询经销商信息
			DealerDetailDto dealerDetailDto = dealerDetailService.getDealerDetailById(storeDto.getDealerId());
			// 转换数据
			invoiceCreateDtos = Arrays.asList(
					Convert.toInvoiceCreateDto(notifyBizDto, orderExclusivel, orderScheduleDto, dealerDetailDto));
			// 生成发票信息
			createInvoice(invoiceCreateDtos, notifyBizDto.getPayNumber());
		} catch (Exception e) {
			String msg = "还款(" + notifyBizDto.getOrderCode() + ":" + notifyBizDto.getScheduleId() + ")支付(支付流水号："
					+ notifyBizDto.getPayNumber() + ")完成创建发票信息异常：";
			logger.error(msg, e);
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + msg + e.getMessage());
		}

	}

	/**
	 * 订购支付发票
	 * 
	 * @param notifyBizDto
	 */
	private void createSubscribeInvoice(NotifyBizDto notifyBizDto) {
		try {
			List<InvoiceCreateDto> invoiceCreateDtos = null;
			// 判断业务类型
			if (PaymentBusinessTypeEnum.EXCLUSIVEL.equals(notifyBizDto.getBusinessType())) {
				// 专属订单
				OrderExclusivelDto orderExclusivel = orderExclusivelService
						.getOrderExclusivel(notifyBizDto.getOrderCode());
				// 查询门店信息
				StoreDto storeDto = storeService.getStoreById(orderExclusivel.getPlaceStoreId());
				// 查询经销商信息
				DealerDetailDto dealerDetailDto = dealerDetailService.getDealerDetailById(storeDto.getDealerId());
				if (OrderPaymentMethodEnum.INSTALLMENT.equals(orderExclusivel.getPaymentMethod())) {
					// 分期订单，查询首期信息
					OrderScheduleDto orderScheduleDto = orderScheduleService
							.getOrderScheduleByPeriods(notifyBizDto.getOrderCode(), 1);
					invoiceCreateDtos = Arrays
							.asList(Convert.toInvoiceCreateDto(notifyBizDto, orderExclusivel, orderScheduleDto,
									dealerDetailDto));
				} else if (OrderPaymentMethodEnum.FULL.equals(orderExclusivel.getPaymentMethod())) {
					// 全款订单，查询排期信息
					List<OrderScheduleDto> orderScheduleDtos = orderScheduleService
							.getOrderSchedule(notifyBizDto.getOrderCode());
					invoiceCreateDtos = Convert.toInvoiceCreateDto(notifyBizDto, orderScheduleDtos, orderExclusivel,
							dealerDetailDto);
				}

			} else if (PaymentBusinessTypeEnum.SUBSCRIBE.equals(notifyBizDto.getBusinessType())) {
				// 订阅订单
				OrderSubscribeDto orderSubscribe = orderSubscribeService.getOrderSubscribe(notifyBizDto.getOrderCode());
				// 查询门店信息
				StoreDto storeDto = storeService.getStoreById(orderSubscribe.getPlaceStoreId());
				// 查询经销商信息
				DealerDetailDto dealerDetailDto = dealerDetailService.getDealerDetailById(storeDto.getDealerId());
				// 转换数据
				invoiceCreateDtos = Arrays
						.asList(Convert.toInvoiceCreateDto(notifyBizDto, orderSubscribe, dealerDetailDto));
			}
			// 生成发票信息
			createInvoice(invoiceCreateDtos, notifyBizDto.getPayNumber());
		} catch (Exception e) {
			String msg = "订购(" + notifyBizDto.getOrderCode() + ")支付(支付流水号：" + notifyBizDto.getPayNumber()
					+ ")完成创建发票信息异常：";
			logger.error(msg, e);
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + msg + e.getMessage());
		}
	}

	/**
	 * 生成发票信息
	 * 
	 * @param invoiceCreateDtos
	 * @param payNumber
	 * @throws Exception
	 */
	private void createInvoice(List<InvoiceCreateDto> invoiceCreateDtos, String payNumber) throws Exception {
		// 生成发票信息
		if (!invoiceService.createInvoiceList(invoiceCreateDtos)) {
			logger.error("支付(支付流水号：" + payNumber + ")完成创建发票信息异常");
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + "支付(支付流水号：" + payNumber + ")完成创建发票信息异常");
		}
	}

	/**
	 * 将用户置为已支付
	 * 
	 * @param userDto
	 */
	private void modifyUserPay(UserDto userDto) {
		try {
			userDetailService.modifyUserPayByUserId(userDto.getId());
		} catch (Exception e) {
			logger.error("支付完成将用户(" + userDto.getId() + ")置为已支付异常：", e);
			DingTalkUtil.exceptionSend(ACTIVE_EXPLAIN + "支付完成将用户(" + userDto.getId() + ")置为已支付异常：" + e.getMessage());
		}
	}
}
